package com.observable.test;

import java.util.Objects;
import java.util.Observable;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @author lzy
 * @date 2020-09-03 下午3:24
 */
public class GPer extends Observable {
    private static GPer gPer = null;
    private final String name = "GPer生态圈";

    private GPer() {
    }

    public static GPer getInstance() {
        if (Objects.isNull(gPer)) {
            gPer = new GPer();
        }

        return gPer;
    }

    public String getName() {
        return name;
    }

    public void publishQuestion(Question question) {
        System.out.println(question.getUserName() + "在" + this.name + "上提交了一个问题.");
        this.setChanged();
        notifyObservers(question);
    }
}
